import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'routes.dart';

List<Widget> _generateRouteItem(
    BuildContext context, List<Map<String,dynamic>> children) {
  return children.map<Widget>((page) {
    return ListTile(
      title: Text(page['title']!),
      trailing: const Icon(Icons.keyboard_arrow_right),
      onTap: () =>  Routes.router.navigateTo(context, page['route']!,transition: TransitionType.inFromRight),
    );
  }).toList();
}

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('测试页面'),
      ),
      body: ListView(
        children:  _generateRouteItem(context, Routes.routesList),
      ),
    );
  }
}
